home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 281_01 / dem_menu.c < prev    next >
C/C++ Source or Header  |  1988-10-05  |  38KB  |  1,030 lines

  1. /*  dem_menu.c
  2.  *
  3.  *  Demo program for menu functions
  4.  *    This program will also spawn the window, data entry and general
  5.  *    library demo programs from a menu.
  6.  *
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <process.h>
  11.  
  12.  
  13. #include "uc_defs.h"
  14. #include "uc_glob.h"
  15. #include "uc_proto.h"
  16.  
  17. #include "wn_defs.h"
  18. #include "wn_glob.h"
  19. #include "wn_proto.h"
  20.  
  21. #include  "mn_defs.h"
  22. #include  "mn_glob.h"
  23.  
  24.  
  25. #include "uc_key.h"
  26.  
  27.  
  28.  
  29. MNUPTR        make_mnu();
  30.  
  31. MNU_ITEMPTR make_item();
  32.  
  33.  
  34.  
  35. void main( void )
  36. {
  37.    MNU_ITEMPTR    mnu_item;
  38.    MNUPTR    mnu_ptr;
  39.    WINDOWPTR    wn_mnu;
  40.    WINDOWPTR    wn_main;
  41.    int        dummy();
  42.    int        bye_bye();
  43.    int        unicorn();
  44.    int        demos();
  45.    int        registration();
  46.    int        future();
  47.    int        notes();
  48.    int        uclib51();
  49.    int        i;
  50.  
  51.    uc_init();    /* This function checks the current video mode and    */
  52.         /* sets up the window system accordingly.          */
  53.         /* At present you must define attributes for either a */
  54.         /* color or a monochrome system.  A future release    */
  55.         /* add a universal attribute system used in a past    */
  56.         /* Unicorn release.  This system allows the user to   */
  57.         /* predefine a set of attributes for both systems and */
  58.         /* to use the appropriate ones determined on a run    */
  59.         /* time check of the video mode.  This means a single */
  60.         /* program may be written that will run correctly on  */
  61.         /* both color and monochrome systems.              */
  62.    if ( mouse_exist )
  63.       m_flagdec();
  64.  
  65.  
  66.    cur_save();    /* Save the users current cursor location and shape.  */
  67.  
  68.  
  69.         /*  Make a full screen window.    This will be popped up*/
  70.         /*  to save the users screen so that it may be          */
  71.         /*  restored on exiting this demo program.          */
  72.    wn_main = wn_make( 0, 0, 24, 80 );
  73.    wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
  74.    wn_bclr( wn_main, mk_att( BLUE,  WHITE + BRIGHT ) );
  75.    wn_clear( wn_main );
  76.    wn_margin( wn_main, 1 );
  77.  
  78.  
  79.         /* A future release will contain a function to build a*/
  80.         /* title so the user will not have to do this messy   */
  81.         /* stuff.  It will be hidden behind a function call.  */
  82.  
  83.    wn_main->title = ( TITLEPTR ) malloc( sizeof( TITLE ) );
  84.    wn_main->title->title = ( char * ) malloc( 100 );
  85.    strcpy( wn_main->title->title,
  86. " Unicorn Software P.O. Box 3214 Kirkland, WA 98034-3214 (206) 823-4656" );
  87.    wn_main->title->position = 4;
  88.                     /* Set the title color          */
  89.    wn_main->clr->title = mk_att( WHITE, BLUE + BRIGHT );
  90.  
  91.  
  92.    wn_mkbdr( wn_main, BDR_LNP );
  93.  
  94.         /* position the cursor in the window and write some   */
  95.         /* text for the user to read.                  */
  96.  
  97.    wn_csr( wn_main, 4, 21 );
  98.    wn_printf( wn_main, "Unicorn Menu System Version 1.0\n" );
  99.  
  100.    wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
  101.    wn_printf( wn_main, "\n                                     " );
  102.    wn_printf( wn_main, "Welcome to the " );
  103.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  104.    wn_printf( wn_main, "Unicorn Menu System\n" );
  105.  
  106.    wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
  107.    wn_printf( wn_main, "                                     " );
  108.    wn_printf( wn_main, "Version 1.0.   This is included as\n" );
  109.  
  110.    wn_printf( wn_main, "                                     " );
  111.    wn_printf( wn_main, "a part of the Unicorn Library.     \n" );
  112.  
  113.    wn_printf( wn_main, "                                     " );
  114.    wn_printf( wn_main, "We hope you enjoy the menu Demo and\n" );
  115.  
  116.    wn_printf( wn_main, "                                     " );
  117.    wn_printf( wn_main, "the other demo programs it will run.\n\n" );
  118.  
  119.    wn_printf( wn_main, "                                     " );
  120.    wn_printf( wn_main, "Not all features are demonstrated but\n" );
  121.  
  122.    wn_printf( wn_main, "                                     " );
  123.    wn_printf( wn_main, "with the source code for this program\n" );
  124.  
  125.    wn_printf( wn_main, "                                     " );
  126.    wn_printf( wn_main, "and the other demos along with the\n" );
  127.  
  128.    wn_printf( wn_main, "                                     " );
  129.    wn_printf( wn_main, "reference guide there should be more\n" );
  130.  
  131.    wn_printf( wn_main, "                                     " );
  132.    wn_printf( wn_main, "than enough to allow you to write\n" );
  133.  
  134.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  135.    wn_printf( wn_main, "    If you have a mouse driver       " );
  136.    wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
  137.    wn_printf( wn_main, "your own programs.  " );
  138.  
  139.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  140.    wn_printf( wn_main, "Registered users \n" );
  141.  
  142.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  143.    wn_printf( wn_main, "    installed, you may use the       " );
  144.    wn_printf( wn_main, "will recieve a " );
  145.  
  146.    wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
  147.    wn_printf( wn_main, "6 disk set " );
  148.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  149.    wn_printf( wn_main, "including\n" );
  150.  
  151.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  152.    wn_printf( wn_main, "    mouse to point and shoot         " );
  153.    wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
  154.    wn_printf( wn_main, "full source code" );
  155.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  156.    wn_printf( wn_main, " for all of the over\n" );
  157.  
  158.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  159.    wn_printf( wn_main, "    with the menus and may use       " );
  160.    wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
  161.    wn_printf( wn_main, "300 functions " );
  162.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  163.    wn_printf( wn_main, "contained in this version\n" );
  164.  
  165.    wn_printf( wn_main, "    the buttons to move through      " );
  166.    wn_printf( wn_main, "of the Unicorn Library.  " );
  167.    wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
  168.    wn_printf( wn_main, "Thanks for\n" );
  169.  
  170.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  171.    wn_printf( wn_main, "    the display instead of           " );
  172.    wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
  173.    wn_printf( wn_main, "looking at the library and considering\n" );
  174.  
  175.    wn_wnclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
  176.    wn_printf( wn_main, "    pressing a key.                  " );
  177.    wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
  178.    wn_printf( wn_main, "registration.        " );
  179.    wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
  180.    wn_printf( wn_main, " Dave Miller\n" );
  181.    wn_wnclr( wn_main, mk_att( BLUE, CYAN ) );
  182.  
  183.  
  184.              /* Time to make a window for the menu.  It will  */
  185.              /* be attached to a menu structure.          */
  186.    wn_mnu = wn_make( 4, 2, 11, 32 );
  187.    wn_wnclr( wn_mnu, mk_att( CYAN, BLACK + BRIGHT ) );
  188.    wn_bclr( wn_mnu, mk_att( CYAN,  BROWN + BRIGHT ) );
  189.    wn_clear( wn_mnu );
  190.    wn_margin( wn_mnu, 2 );
  191.    wn_mkbdr( wn_mnu, BDR_DLNP );
  192.  
  193.              /* Make the menu structure now.              */
  194.    mnu_ptr = make_mnu( wn_mnu );
  195.  
  196.    wn_printf( mnu_ptr->mnu_window, "        Main Menu\n" );
  197.  
  198.  
  199.              /* Now we will make the actual menu items.  Each */
  200.              /* item call is passed several parameters.  You  */
  201.              /* may easily experiment with changing them to   */
  202.              /* get a better feel for the system.  One very   */
  203.              /* important one is the pointer to a function to */
  204.              /* be called if this item is selected.  For the  */
  205.              /* first item the pointer is 'unicorn'.          */
  206.  
  207.    mnu_item = make_item( 3, 4, mk_att( CYAN, BLUE ),
  208.         mk_att( BLUE, CYAN + BRIGHT ), " Unicorn Software ", unicorn,
  209.             'U', mk_att( CYAN, RED ), mnu_ptr );
  210.  
  211.    mnu_item = make_item( 4, 4, mk_att( CYAN, BLUE ),
  212.         mk_att( BLUE, CYAN + BRIGHT ), " Demo Programs    ", demos,
  213.             'D', mk_att( CYAN, RED ), mnu_ptr );
  214.  
  215.    mnu_item = make_item( 5, 4, mk_att( CYAN, BLUE ),
  216.         mk_att( BLUE, CYAN + BRIGHT ), " Registration    ", registration,
  217.              'R', mk_att( CYAN, RED ), mnu_ptr );
  218.  
  219.    mnu_item = make_item( 6, 4, mk_att( CYAN, BLUE ),
  220.         mk_att( BLUE, CYAN + BRIGHT ), " Future Updates  ", future,
  221.               'F', mk_att( CYAN, RED ), mnu_ptr );
  222.  
  223.    mnu_item = make_item( 7, 4, mk_att( CYAN, BLUE ),
  224.         mk_att( BLUE, CYAN + BRIGHT ), " Library Notes   ", notes,
  225.